import React,{Component} from 'react'

function IsLogin(Com){
    return class extends Component{
        state = {
            islogin:false //记录登录状态
        }
        componentDidMount(){
            if(localStorage.getItem('token')){
                //登录
                this.setState({
                    islogin:true
                })
            }else{
                //没有登录
                this.props.history.push('/login');
            }
        }
        render(){
            let {islogin} = this.state;
            return islogin ? <Com {...this.props}/> :<></>
        }
    }
}

export default IsLogin